#include <iostream> 
using namespace std;

#include "list.h"


void test_list1()
{
	ykh::list<int> lt;

	lt.push_front(1);
	lt.push_front(2);
	lt.push_front(3);
	lt.push_front(4);

	ykh::list<int>::iterator it = lt.begin();
	while (it != lt.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	lt.pop_front();
	lt.pop_front();
	lt.pop_front();
	lt.pop_front();

	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	lt.pop_back();
	lt.pop_back();
	lt.pop_back();
	lt.pop_back();

	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;
}

void testlist2()
{
	ykh::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	for (auto e : lt)
	{
		cout << e << " ";
	}
	cout << endl;

	ykh::list<int> lt1(lt.begin(), lt.end());

	for (auto e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	ykh::list<int> lt2 = lt1;

	for (auto e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
}

void print_list(const ykh::list<int>& lt)
{
	ykh::list<int>::const_iterator cit = lt.begin();
	while (cit != lt.end())
	{
		cout << *cit << " ";
		++cit;
	}
	cout << endl;
}

void testlist3()
{
	ykh::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	print_list(lt);

	ykh::list<int>::iterator it = lt.begin();
	while (it != lt.end())
	{
		cout << ((*it) *= 2) << " ";
		++it;
	}
	cout << endl;
}

void testlist4()
{
	ykh::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	ykh::list<int>::reverse_iterator rit = lt.rbegin();
	while (rit != lt.rend())
	{
		cout << *rit << " ";
		++rit;
	}
	cout << endl;
}

int main()
{
	//test_list1();
	//testlist2();
	//testlist3();
	testlist4();

	return 0;
}